import React, { Component } from 'react';

class Login extends Component {
    state = {
        userName: 'lisi',
        passWord: "if(1===1){console.log('iloveyou')}"
    }
    changeHandler(e) {
        this.setState({
            [e.target.name]: e.target.value
        })
    }
    submitHandler(e) {
        e.preventDefault();
        console.log(this.state.userName, this.state.passWord);

    }
    render() {
        return (
            <div>
                <h3>登陆</h3>
                <form onSubmit={this.submitHandler.bind(this)}>
                    <p>用户名:<input type="text" value={this.state.userName} name={"userName"} onChange={this.changeHandler.bind(this)} /></p>
                    <p>密码:<input type="password" name={"passWord"} value={this.state.passWord} onChange={this.changeHandler.bind(this)} /></p>
                    <button>提交</button>

                </form>
            </div>
        )
    }
}
export default Login;
